//
//  MYNavigationController.swift
//  NewMicroblog
//
//  Created by apple on 2016/10/22.
//  Copyright © 2016年 apple. All rights reserved.
//

import UIKit

class MYNavigationController: UINavigationController,UIGestureRecognizerDelegate{

    override func viewDidLoad() {
        super.viewDidLoad()
        interactivePopGestureRecognizer?.delegate = self;

    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
       
    }
    func popVC(){
        popViewController(animated: true)
    }
    
    
    override func pushViewController(_ viewController: UIViewController, animated: Bool){
       
        var title = "返回"

        if childViewControllers.count == 1 {
            
            title = (childViewControllers.first?.title) ?? ""
        }
        
      viewController.navigationItem.leftBarButtonItem = UIBarButtonItem(imageName: "navigationbar_back_withtext", title: title, target: self, action: #selector(popVC))
        super.pushViewController(viewController, animated: animated)
    }
    func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldReceive touch: UITouch) -> Bool {
        return childViewControllers.count != 1
    }
    


}
